<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2014 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: Dean <zxxjjforever@163.com>
// +----------------------------------------------------------------------
/**
 * 搜索结果页面
 */
namespace Portal\Controller;
use Common\Controller\HomeBaseController;
class SearchController extends HomeBaseController {
    //文章内页
    public function index() {
		$k = I("keyword");
		if (empty($k)) {
			$this -> error("关键词不能为空！请重新输入！");
		}
        $where="post_title LIKE '%".$k."%' and post_status=1";
        $count=M('Posts')->where($where)->count();
        $Page       = new \Think\Page($count,10);// 实例化分页类 传入总记录数和每页显示的记录数(25)

        $list=M('Posts')->where($where)->limit($Page->firstRow.','.$Page->listRows)->select();
        $this->assign('Page',$Page->show());
        $this->assign('list',$list);
		$this -> display();
    }
    
    
}
